2000W / 48V LLC Battery-Charger  V1.00
xmc_rtc.h
Go to the documentation of this file.
1 
57 #ifndef XMC_RTC_H
58 #define XMC_RTC_H
59 
60 /*********************************************************************************************************************
61  * HEADER FILES
62  *********************************************************************************************************************/
63 
64 #include <xmc_common.h>
65 #include <time.h>
66 
89 /*********************************************************************************************************************
90  * MACROS
91  *********************************************************************************************************************/
92 
93 /*********************************************************************************************************************
94  * ENUMS
95  *********************************************************************************************************************/
96 
100 typedef enum XMC_RTC_STATUS
101 {
106 
110 typedef enum XMC_RTC_EVENT
111 {
120 
124 typedef enum XMC_RTC_MONTH
125 {
139 
143 typedef enum XMC_RTC_WEEKDAY
144 {
153 
154 /*********************************************************************************************************************
155  * DATA STRUCTURES
156  *********************************************************************************************************************/
157 /*Anonymous structure/union guard start*/
158 #if defined(__CC_ARM)
159  #pragma push
160  #pragma anon_unions
161 #elif defined(__TASKING__)
162  #pragma warning 586
163 #endif
164 
165 
175 typedef struct XMC_RTC_ALARM
176 {
177  union
178  {
179  uint32_t raw0;
180  struct
181  {
182  uint32_t seconds : 6;
183  uint32_t : 2;
184  uint32_t minutes : 6;
185  uint32_t : 2;
186  uint32_t hours : 5;
187  uint32_t : 3;
188  uint32_t days : 5;
189  uint32_t : 3;
190  };
191  };
192 
193  union
194  {
195  uint32_t raw1;
196  struct
197  {
198  uint32_t : 8;
199  uint32_t month : 4;
200  uint32_t : 4;
201  uint32_t year : 16;
202  };
203  };
205 
215 typedef struct XMC_RTC_TIME
216 {
217  union
218  {
219  uint32_t raw0;
220  struct
221  {
222  uint32_t seconds : 6;
223  uint32_t : 2;
224  uint32_t minutes : 6;
225  uint32_t : 2;
226  uint32_t hours : 5;
227  uint32_t : 3;
228  uint32_t days : 5;
229  uint32_t : 3;
230  };
231  };
232 
233  union
234  {
235  uint32_t raw1;
236  struct
237  {
238  uint32_t daysofweek : 3;
239  uint32_t : 5;
240  uint32_t month : 4;
241  uint32_t : 4;
242  uint32_t year : 16;
243  };
244  };
246 /*Anonymous structure/union guard end*/
247 #if defined(__CC_ARM)
248  #pragma pop
249 #elif defined(__TASKING__)
250  #pragma warning restore
251 #endif
252 
260 typedef struct XMC_RTC_CONFIG
261 {
264  uint16_t prescaler;
266 
267 /*******************************************************************************
268  * EXTENSIONS
269  *******************************************************************************/
270 
271 #if UC_FAMILY == XMC1
272 #include "xmc1_rtc.h"
273 #endif
274 
275 #if UC_FAMILY == XMC4
276 #include "xmc4_rtc.h"
277 #endif
278 
279 /*******************************************************************************
280  * API PROTOTYPES
281  *********************************************************************************************************************/
282 
283 #ifdef __cplusplus
284 extern "C" {
285 #endif
286 
307 XMC_RTC_STATUS_t XMC_RTC_Init(const XMC_RTC_CONFIG_t *const config);
308 
326 void XMC_RTC_Enable(void);
327 
345 void XMC_RTC_Disable(void);
346 
365 bool XMC_RTC_IsEnabled(void);
366 
381 void XMC_RTC_Start(void);
382 
396 void XMC_RTC_Stop(void);
397 
414 void XMC_RTC_SetPrescaler(uint16_t prescaler);
415 
431 {
432  return (uint32_t)(((uint32_t)RTC->CTR & (uint32_t)RTC_CTR_DIV_Msk) >> (uint32_t)RTC_CTR_DIV_Pos);
433 }
434 
451 void XMC_RTC_SetTime(const XMC_RTC_TIME_t *const timeval);
452 
468 void XMC_RTC_GetTime(XMC_RTC_TIME_t *const time);
469 
485 void XMC_RTC_SetTimeStdFormat(const struct tm *const stdtime);
486 
505 void XMC_RTC_GetTimeStdFormat(struct tm *const stdtime);
506 
523 void XMC_RTC_SetAlarm(const XMC_RTC_ALARM_t *const alarm);
524 
541 void XMC_RTC_GetAlarm(XMC_RTC_ALARM_t *const alarm);
542 
558 void XMC_RTC_SetAlarmStdFormat(const struct tm *const stdtime);
559 
578 void XMC_RTC_GetAlarmStdFormat(struct tm *const stdtime);
579 
597 void XMC_RTC_EnableEvent(const uint32_t event);
598 
616 void XMC_RTC_DisableEvent(const uint32_t event);
617 
634 void XMC_RTC_ClearEvent(const uint32_t event);
635 
650 uint32_t XMC_RTC_GetEventStatus(void);
651 
667 {
668  return (bool)(RTC->CTR & RTC_CTR_ENB_Msk);
669 }
670 
671 #ifdef __cplusplus
672 }
673 #endif
674 
683 #endif /* XMC_RTC_H */
void XMC_RTC_ClearEvent(const uint32_t event)
Definition: xmc1_rtc.c:147
uint32_t hours
Definition: xmc_rtc.h:226
bool XMC_RTC_IsEnabled(void)
Definition: xmc1_rtc.c:155
XMC_RTC_STATUS_t XMC_RTC_Init(const XMC_RTC_CONFIG_t *const config)
RTC driver for XMC microcontroller family.
Definition: xmc1_rtc.c:74
void XMC_RTC_SetPrescaler(uint16_t prescaler)
Definition: xmc_rtc.c:117
#define RTC
Definition: XMC1400.h:8818
uint32_t month
Definition: xmc_rtc.h:240
uint32_t raw1
Definition: xmc_rtc.h:195
uint32_t minutes
Definition: xmc_rtc.h:184
uint32_t raw0
Definition: xmc_rtc.h:179
#define RTC_CTR_ENB_Msk
Definition: XMC1400.h:2048
void XMC_RTC_SetAlarm(const XMC_RTC_ALARM_t *const alarm)
Definition: xmc_rtc.c:214
void XMC_RTC_Disable(void)
Definition: xmc1_rtc.c:113
void XMC_RTC_EnableEvent(const uint32_t event)
Definition: xmc1_rtc.c:131
uint32_t raw1
Definition: xmc_rtc.h:235
uint32_t year
Definition: xmc_rtc.h:242
#define RTC_MSKSR_MPMO_Msk
Definition: XMC1400.h:2096
#define RTC_MSKSR_MPYE_Msk
Definition: XMC1400.h:2098
XMC_RTC_STATUS
Definition: xmc_rtc.h:100
#define RTC_MSKSR_MPDA_Msk
Definition: XMC1400.h:2094
XMC_RTC_MONTH
Definition: xmc_rtc.h:124
uint32_t hours
Definition: xmc_rtc.h:186
void XMC_RTC_DisableEvent(const uint32_t event)
Definition: xmc1_rtc.c:139
void XMC_RTC_Enable(void)
Definition: xmc1_rtc.c:105
XMC_RTC_ALARM_t alarm
Definition: xmc_rtc.h:263
uint32_t month
Definition: xmc_rtc.h:199
void XMC_RTC_SetAlarmStdFormat(const struct tm *const stdtime)
Definition: xmc_rtc.c:259
XMC_RTC_EVENT
Definition: xmc_rtc.h:110
uint32_t raw0
Definition: xmc_rtc.h:219
#define RTC_MSKSR_MPHO_Msk
Definition: XMC1400.h:2092
__STATIC_INLINE bool XMC_RTC_IsRunning(void)
Definition: xmc_rtc.h:666
enum XMC_RTC_STATUS XMC_RTC_STATUS_t
#define RTC_CTR_DIV_Msk
Definition: XMC1400.h:2052
struct XMC_RTC_ALARM XMC_RTC_ALARM_t
void XMC_RTC_GetTime(XMC_RTC_TIME_t *const time)
Definition: xmc_rtc.c:168
void XMC_RTC_Stop(void)
Definition: xmc_rtc.c:105
#define RTC_CTR_DIV_Pos
Definition: XMC1400.h:2051
void XMC_RTC_GetTimeStdFormat(struct tm *const stdtime)
Definition: xmc_rtc.c:196
uint32_t XMC_RTC_GetEventStatus(void)
Definition: xmc_rtc.c:295
void XMC_RTC_SetTime(const XMC_RTC_TIME_t *const timeval)
Definition: xmc_rtc.c:132
enum XMC_RTC_MONTH XMC_RTC_MONTH_t
struct XMC_RTC_CONFIG XMC_RTC_CONFIG_t
enum XMC_RTC_EVENT XMC_RTC_EVENT_t
XMC_RTC_TIME_t time
Definition: xmc_rtc.h:262
__STATIC_INLINE uint32_t XMC_RTC_GetPrescaler(void)
Definition: xmc_rtc.h:430
uint32_t days
Definition: xmc_rtc.h:228
void XMC_RTC_GetAlarm(XMC_RTC_ALARM_t *const alarm)
Definition: xmc_rtc.c:249
XMC_RTC_WEEKDAY
Definition: xmc_rtc.h:143
uint32_t seconds
Definition: xmc_rtc.h:182
void XMC_RTC_SetTimeStdFormat(const struct tm *const stdtime)
Definition: xmc_rtc.c:177
uint32_t daysofweek
Definition: xmc_rtc.h:238
void XMC_RTC_Start(void)
Definition: xmc_rtc.c:93
#define __STATIC_INLINE
Definition: cmsis_gcc.h:47
uint32_t year
Definition: xmc_rtc.h:201
#define RTC_MSKSR_MAI_Msk
Definition: XMC1400.h:2100
#define RTC_MSKSR_MPMI_Msk
Definition: XMC1400.h:2090
uint32_t minutes
Definition: xmc_rtc.h:224
uint32_t seconds
Definition: xmc_rtc.h:222
struct XMC_RTC_TIME XMC_RTC_TIME_t
enum XMC_RTC_WEEKDAY XMC_RTC_WEEKDAY_t
#define RTC_MSKSR_MPSE_Msk
Definition: XMC1400.h:2088
void XMC_RTC_GetAlarmStdFormat(struct tm *const stdtime)
Definition: xmc_rtc.c:277
uint16_t prescaler
Definition: xmc_rtc.h:264
uint32_t days
Definition: xmc_rtc.h:188